package com.weimob.mcloud.wechatwork.customer.constant;

/**
 * 幂等校验配置
 * @author tao.gu02
 * @since 1.0
 */
public class RedisLockConstant {

    public static final int lockTime = 3;

    public static String DismisGroup = "DismissGroup_%s_%s";

    public static String CreateGroup = "CreateGroup_%s_%s";

    public static String DelCorpExternaluser = "DelCorpExternaluser_%s_%s_%s_%s";

    public static String INIT_TAG = "initTag_%s";

    /**
     * 统计独用的键名
     */
    public static String DelCorpExternaluser2 = "DelCorpExternaluserMyOwn_%s_%s_%s";

    public static String AddCorpExternaluser = "AddCorpExternaluser_%s_%s_%s_%s";

    public static String CREATE_TAG_GROUP = "createTagGroup_%s_%s_%s";

    public static String CREATE_TAG = "createTag_%s_%s_%s";

    public static String CUSTOMER_GROUP_JOIN_STATISTIC = "customer:group:join:statistic:%s:%s";

    public static String CUSTOMER_GROUP_JOIN_STATISTIC_BOS = "customer:group:join:statistic:bos:%s";

    public static String CUSTOMER_GROUP_QUIT_STATISTIC = "customer:group:quit:statistic:%s:%s";

    public static String CUSTOMER_GROUP_QUIT_STATISTIC_BOS = "customer:group:quit:statistic:corp:%s";


    public static String STATISTIC_NON_FRIEND_TASK_KEY = "statistic:non:friend:task:bos:%s";



    /**
     * 流失客户幂等
     */
    public static String customerLose = "CustomerLose_%s_%s_%s";

    public static String TAG_CHANGE_KEY = "corpTagChange_%s_%s_%s_%s_%s_%s_%s";

    public static String CUSTOMER_TAG_CHANGE_KEY = "corpCustomerTagChange_%s_%s_%s";

    /**
     * 客户群同步使用
     */
    public static final String CUSTOMER_GROUP_SYNC_LOCK = "wechatWork:customer:groupSyncLock:%s_%s";

    public static final int CUSTOMER_GROUP_SYNC_LOCK_EXPIRE = 120;

    /**
     * 外部联系人消息重试
     */
    public static String ADD_EXTERNAL_USER_RETRY = "wechatWork:customer:add_external_user_retry:";

    public static String CUSTOMER_TAG_SYNC = "customerTagSync_%s_%s";

    public static String HISTORY_CUSTOMER_SYNC = "wechatwork:customer:server:history:customerSync_%s_%s_%s";

    public static String getCustomerTagSyncKey(String externalUserId, String userId) {
        return String.format(CUSTOMER_TAG_SYNC, externalUserId, userId);
    }

    /**
     * 历史客户数据同步缓存key
     * @param corpId
     * @param externalUserId
     * @return
     */
    public static String getHistoryCustomerSyncKey(Long bosId, String corpId, String externalUserId) {
        return String.format(HISTORY_CUSTOMER_SYNC, bosId, corpId, externalUserId);
    }

}
